<?php
$table_source = $old_nav_db_config['DB_PREFIX'].'site';
$table_target = $db_config['DB_PREFIX'].'site';

$db_target->query("TRUNCATE $table_target");
$data_list = $db_source->query("SELECT * FROM $table_source");
showjsmessage("开始转换数据表　site",2);
$data_count = count($data_list);
$data = $data_list[0];
unset($data['collect_count']);
unset($data['update_time']);
$fields = array_keys($data);
$start_sql = "INSERT INTO $table_target ( `" . implode('`, `', $fields) . '`, `user_id`) VALUES ';

for($j=0; $j< $data_count; $j++)
{
	$data = $data_list[$j];
	unset($data['collect_count']);
	unset($data['update_time']);
	$data['site_img'] = preg_replace("/^\/Public/", '/public', $data['site_img']);
	$user_id = $db_source->query("SELECT id FROM ".$old_nav_db_config['DB_PREFIX']."user WHERE rec_id = '$data[id]'");
	if(count($user_id) > 0)
		$user_id = intval($user_id[0]['id']);
	else
		$user_id = 0;
	
	$record = array_map('dumpEscapeString',$data);//过滤非法字符
	$sql = $start_sql . ' ('. implodeInsertValues($record) .','.$user_id.')';
	$db_target->query($sql);
}

showjsmessage("转换数据表　site ... 成功");

showjsmessage(U('Index/convert',array('table'=>'site_cate','begin'=>0)),5);
?>